package io.renren.modules.archive.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.archive.entity.BgqxEntity;
import io.renren.modules.archive.service.BgqxService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * ${comments}
 *
 * @author lizeliang
 * @email 2749877017@qq.com
 * @date 2023-09-01 17:18:13
 */
@RestController
@RequestMapping("archive/bgqx")
public class BgqxController {
    @Autowired
    private BgqxService bgqxService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("archive:bgqx:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bgqxService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bgqxId}")
//    @RequiresPermissions("archive:bgqx:info")
    public R info(@PathVariable("bgqxId") Long bgqxId){
		BgqxEntity bgqx = bgqxService.getById(bgqxId);

        return R.ok().put("bgqx", bgqx);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("archive:bgqx:save")
    public R save(@RequestBody BgqxEntity bgqx){
		bgqxService.save(bgqx);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("archive:bgqx:update")
    public R update(@RequestBody BgqxEntity bgqx){
		bgqxService.updateById(bgqx);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("archive:bgqx:delete")
    public R delete(@RequestBody Long[] bgqxIds){
		bgqxService.removeByIds(Arrays.asList(bgqxIds));

        return R.ok();
    }


    @RequestMapping("/selectBgqx")
    public R selectBgqx(@RequestParam Map<String, Object> params){
        String bgqxId=(String)params.get("bgqxId");
        BgqxEntity bgqxEntity=bgqxService.getById(bgqxId);

        return R.ok().put("bgqx",bgqxEntity.getBgqx());
    }

}
